<h1>Editando notícia</h1>

<%= error_messages_for :post %>

<% form_for(@post, :url => admin_post_path(@post), :html => { :multipart => true }) do |f| %>
  <p>
    <b>Autor</b><br />
    <%= f.text_field :autor, :value => current_user.login, :readonly=>"readonly" %>
  </p>

  <p>
    <b>Título</b><br />
    <%= f.text_field :title %>
  </p>

  <p><b>Texto</b></p>
   <%= f.text_area :body %>
	<br/>

  <p class="text_hint">
  	apenas imagens com no máximo 500kb.
  </p>
  
  <div id="upload_images">
    <b>Imagens:</b><br/>
	<% for images in @post.post_images %>
		<div class="image_field">
		  <p>
		  <% fields_for "post[update_images][]", images  do |f|%>
			    	<%= link_to image_tag(images.public_filename(:thumb)), images.public_filename, :target => "_blank" %>
		        <%= link_to_function "remover", "mark_for_destroy(this)"%>        
		        <%= f.hidden_field :id, :index => nil %>
		        <%= f.hidden_field :should_destroy, :index => nil, :class => "should_destroy" %>
		  <% end %>
		  </p>
		</div>		
	<% end %>
  </div>

  <p><%= add_image_field "Adicionar mais imagens"%></p>

  <p>
    <%= f.submit "Atualizar" %>
  </p>
<% end %>

<%= link_to 'Exibir', admin_post_path(@post) %> |
<%= link_to 'Voltar', admin_posts_path %>

<%= niceditor %>